// pages/classify/classify.js
var indexData = require('../../data/indexData.js');

Page({

  /**
   * 页面的初始数据
   */
  data: {
    animation1: null, //正面卡片动画
    animation2: null, //背面卡片动画
    /**品牌导航 */
    tabBrandList: null,
    inter: '',
    pointId:1,
    Interval: null, // 定时器声明时赋值
    Numbers: 0,
  },
  brandListShow: function (e) {
    var tabBrandList = indexData.tabBrandList[e];
    console.log("brand=" + e);
    this.setData({
      tabBrandList: tabBrandList
    })
  },
  rotateFn(e) {
    let that = this
    let id = e.currentTarget.dataset.id
    // let id = e;
    console.log("xxxx="+e)
    // 点击正面
    if (id == 1) {
      this.setData({
        animation1: that.animation.rotateY(180).step().export(),
        animation2: that.animation.rotateY(0).step().export(),
        id: 2
      })
    } else { //点击反面
      this.setData({
        animation1: that.animation.rotateY(0).step().export(),
        animation2: that.animation.rotateY(180).step().export(),
        id: 1
      })
    }
  },
  /**
   * 生命周期函数--监听页面加载
   */
  animation: wx.createAnimation({
    duration: 1000,
    timingFunction: 'linear'
  }),
  onLoad(options) {
    //加载品牌分类导航
    this.brandListShow(1);
    // 加载定时任务
    // this.startInter();
    console.log("pointId="+this.data.pointId);    
    this.cardListTime(); 
  },
  onReady() {
    console.log("onReady......");

  },

  cardListTime : function(params) {
    this.data.Interval = setInterval(() => {
      console.log("pointId="+this.data.pointId);
      this.rotateFn(this.data.pointId);
      this.setData({
        Numbers: ++this.data.Numbers
      })
    }, 3000);
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    console.log("onShow......");
    let that = this
    clearInterval(that.data.Interval);
    // that.cardListTime(); 
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {
    console.log("onHide......");
    let that = this
    clearInterval(that.data.Interval);
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {
    console.log("onUnload......");
    let that = this
    clearInterval(that.data.Interval);
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  },

}
)